#!/usr/bin/python3
# -- coding: utf-8 -- 
# 原作者
# @Author : gitee@litey https://gitee.com/litey
# @Time : 2025/7/15 13:23
# -------------------------------
'''
cron: 0 10 8 * * *
const $ = new Env('ole')

#登录后搜索https://ole-app.crvole.com.cn/vgdt_app_api/v1/vgdt-fea-app-member/front_api/member_sign域名随意一个 请求体里面的sessionId 多账号用英文&隔开
oleid 值sessionId1&sessionId2

'''

import requests,json
import os

# 青龙变量 oleid
ole_id = os.getenv("oleid").split('&')

#推送加 token
plustoken = os.getenv("PUSH_PLUS_TOKEN")

def Push(contents):
  # plustoken推送
    headers = {'Content-Type': 'application/json'}
    json = {"token": plustoken, 'title': 'ole签到', 'content': contents.replace('\n', '<br>'), "template": "json"}
    resp = requests.post(f'http://www.pushplus.plus/send', json=json, headers=headers).json()
    print('push+推送成功' if resp['code'] == 200 else 'push+推送失败')

print(f'共配置了{len(ole_id)}个账号')
log = []
for i in range(len(ole_id)):
    print(f'*****第{str(i+1)}个账号*****')
    url = "https://ole-app.crvole.com.cn/vgdt_app_api/v1/vgdt-fea-app-member/front_api/member_sign"
    headers = {
      "Host": "ole-app.crvole.com.cn",
      "User-Agent": "Ole4iPhone/4.0.0 (com.crv.ole; build:5; iOS 26.0.0) Alamofire/5.10.2",
      "Connection": "keep-alive",
      "sessionId": ole_id[i],
      "Content-Type": "application/json",
      "Touch-Point": "APP_IOS"
    }
    data = """{\"enter_shop_code\":\"207168\"}"""

    html = requests.post(url, headers=headers, data=data)
    print(html.text)
    result = f'帐号{i+1}签到响应结果:'+'' +json.loads(html.text)['message']
    res='' +json.loads(html.text)['message']
    print(res)
    if res=='' or res=='当日签到已完成，请勿重复签到！':
        result = f'帐号{i+1}签到结果:'+'成功'
    else:
        result = f'帐号{i+1}签到结果:'+'失败'
    print(result)
    log.append(result)
    log2 = str(log).replace('[\'','').replace('\']','').replace(':','\n').replace('\', \'','\n')
    print(log2)
Push(contents=log2)